﻿<UserControl x:Class="PluginSample2.StrategyControl"
			 x:ClassModifier="internal"
			 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             
             xmlns:Converters="clr-namespace:Utils.Wpf.Converters;assembly=Utils"
             xmlns:PluginSample2="clr-namespace:PluginSample2" Background="#1F1F1F"
             
             mc:Ignorable="d"
             
             d:DesignHeight="130"
			 d:DataContext="{d:DesignInstance Type=PluginSample2:StrategyControlVM}" >

	<UserControl.Resources>
		<ResourceDictionary>
			<Converters:MultiplierConverter x:Key="MultiplierConverter" />
			<Converters:EnumToBooleanConverter x:Key="EnumToBooleanConverter" />
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="pack://application:,,,/Plugins;component/PluginTheme.xaml" />
			</ResourceDictionary.MergedDictionaries>
		</ResourceDictionary>
	</UserControl.Resources>
	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="*" />
			<RowDefinition Height="*" />
			<RowDefinition Height="*" />
			<RowDefinition Height="*" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>

		<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="10" Text="Execution Parameters" HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="Header" Margin="6" />

		<!-- Mode -->
		<GroupBox Grid.Row="1" Grid.Column="0" Grid.RowSpan="3" Margin="5,0,5,0" Header="Mode" >
			<StackPanel>
				<RadioButton GroupName="ExecutionDirection" Content="Up" IsChecked="{Binding Mode, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter=Up, Mode=TwoWay}" />
				<RadioButton GroupName="ExecutionDirection" Content="Down" IsChecked="{Binding Mode, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter=Down, Mode=TwoWay}" />
				<RadioButton GroupName="ExecutionDirection" Content="Up &amp; Down" IsChecked="{Binding Mode, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter=UpAndDown, Mode=TwoWay}" />
			</StackPanel>
			<GroupBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="ExecutionDirection" />
					<TextBlock Foreground="Black" Text="Selects if operations will be done on markets going up, down or both." />
				</StackPanel>
			</GroupBox.ToolTip>
		</GroupBox>

		<!-- Internal Separator -->
		<Border Grid.Row="1" Grid.Column="2" Grid.RowSpan="4" BorderBrush="{StaticResource SelectedRowBrush}" Background="{StaticResource SelectedRowBrush}" BorderThickness="1" Margin="10,0,10,0" />

		<!-- Numeric Parameters -->
		<TextBlock Grid.Row="1" Grid.Column="3" Margin="3,3,6,3" Text="Bar Duration" VerticalAlignment="Center" />
		<TextBox Grid.Row="1" Grid.Column="4" Margin="0,0,0,1"  HorizontalContentAlignment="Right" Text="{Binding BarDuration, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged}" Width="{Binding ActualWidth, ElementName=Header, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.3}" >
			<TextBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Bar Duration" />
					<TextBlock Foreground="Black" Text="The duration in minutes of each bar used by the strategy. An usual value is 5 minutes." />
				</StackPanel>
			</TextBox.ToolTip>
		</TextBox>
		<TextBlock Grid.Row="1" Grid.Column="5" Margin="3" Text="min" />

		<TextBlock Grid.Row="2" Grid.Column="3" Margin="3,3,6,3" Text="Consecutive Bars" VerticalAlignment="Center"  />
		<TextBox Grid.Row="2" Grid.Column="4" Margin="0,1,0,1" HorizontalContentAlignment="Right" Text="{Binding BarQuantity, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged}" Width="{Binding ActualWidth, ElementName=Header, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.3}" >
			<TextBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Consecutive Bars" />
					<TextBlock Foreground="Black" Text="The number of consecutive bars with growing minimuns or dropping maximums (depending on the mode) to execute an operation." />
				</StackPanel>
			</TextBox.ToolTip>
		</TextBox>

		<TextBlock Grid.Row="3" Grid.Column="3" Margin="3,3,6,3" Text="Volume" VerticalAlignment="Center"  />
		<TextBox Grid.Row="3" Grid.Column="4" Margin="0,1,0,0"  HorizontalContentAlignment="Right" Text="{Binding QuantityToBuy, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=PropertyChanged}" Width="{Binding ActualWidth, ElementName=Header, Converter={StaticResource MultiplierConverter}, ConverterParameter=0.3}" >
			<TextBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Volume" />
					<TextBlock Foreground="Black" Text="The number of items to buy/sell on each operation." />
				</StackPanel>
			</TextBox.ToolTip>
		</TextBox>

		<!-- Internal Separator -->
		<Border Grid.Row="1" Grid.Column="6" Grid.RowSpan="4" BorderBrush="{StaticResource SelectedRowBrush}" Background="{StaticResource SelectedRowBrush}" BorderThickness="1" Margin="10,0,10,0" />

		<!-- Volume management -->
		<GroupBox Grid.Row="1" Grid.Column="7" Grid.RowSpan="3" Margin="5,0,5,0" Header="Bar Source" >
			<StackPanel>
				<RadioButton Content="Last Value" IsChecked="{Binding BarSource, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter=LastValue}" />
				<RadioButton Content="Bid/Ask Average" IsChecked="{Binding BarSource, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter=AverageBidAsk}" />
				<RadioButton Content="Max Ask/Min Bid" IsChecked="{Binding BarSource, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter=MaxAskMinBid}" />
			</StackPanel>
			<GroupBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Bar Source" />
					<TextBlock Foreground="Black" Text="The source of the data to calculate the max and the min value." />
				</StackPanel>
			</GroupBox.ToolTip>
		</GroupBox>
		
		<!-- Internal Separator -->
		<Border Grid.Row="1" Grid.Column="8" Grid.RowSpan="4" BorderBrush="{StaticResource SelectedRowBrush}" Background="{StaticResource SelectedRowBrush}" BorderThickness="1" Margin="10,0,10,0" />

		<!-- Boolean Parameters -->
		<CheckBox Grid.Row="1" Grid.Column="9" Content="Invert Logic" IsChecked="{Binding InvertLogic}" VerticalAlignment="Center" >
			<CheckBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Invert Logic" />
					<TextBlock Foreground="Black" Text="If active a sell is done when a buy should be done and the other way around." />
				</StackPanel>
			</CheckBox.ToolTip>
		</CheckBox>
		<CheckBox Grid.Row="2" Grid.Column="9" Content="Require Pure Bars" IsChecked="{Binding RequirePureBars}" VerticalAlignment="Center" >
			<CheckBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Require Pure Bars" />
					<TextBlock Foreground="Black" Text="If active growing or decreasing max and mins will be required at the same time." />
				</StackPanel>
			</CheckBox.ToolTip>
		</CheckBox>
	</Grid>
</UserControl>
